var FollowTableList = {// 医生随访表格初始化
    id: "FollowTableList",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

function _cellStyles(value, row, index) {
    if (row.revisitStatus == 2) {
        return {
            css: {"background-color": "#fff1d5", "overflow": "hidden", "white-space": "nowrap", "text-overflow": "ellipsis"}
        }
    } else {
        return {css: {"overflow": "hidden", "white-space": "nowrap", "text-overflow": "ellipsis"}}
    }
}

FollowTableList.initColumn = function () {//初始化表格的列
    var columns = [
        {title: 'id', field: 'id', visible: false, align: 'center', valign: 'middle'},
        {title: 'customerId', field: 'customerId', visible: false, align: 'center', valign: 'middle'},
        {title: '诊所', field: 'arrivalStore', align: 'center', valign: 'middle', sortable: true,width:90,
            cellStyle: function (value, row, index) {
                return _cellStyles(value, row, index);
            }
        },
        {title: '随访时间', field: 'revisitTime', align: 'center', valign: 'middle', sortable: true,width:120,
            formatter: function (value, row, index) {
                return value.substring(0, 11);
            },
            cellStyle: function (value, row, index) {
                return _cellStyles(value, row, index);
            }
        },
        {title: '患者姓名', field: 'customerName', align: 'center', valign: 'middle', sortable: true,width:110,
            cellStyle: function (value, row, index) {
                return _cellStyles(value, row, index);
            }
        },
        {title: '随访医生', field: 'doctor', align: 'center', valign: 'middle', sortable: true,width:110,
            cellStyle: function (value, row, index) {
                return _cellStyles(value, row, index);
            }
        },
        {title: '随访人员', field: 'revisit', align: 'center', valign: 'middle', sortable: true,width:110,
            cellStyle: function (value, row, index) {
                return _cellStyles(value, row, index);
            }
        },
        {title: '咨询师', field: 'fieldTc', align: 'center', valign: 'middle', sortable: true,width:90,
            cellStyle: function (value, row, index) {
                return _cellStyles(value, row, index);
            }
        },
        {title: '创建人', field: 'createName', align: 'center', valign: 'middle', sortable: true,width:90,
            cellStyle: function (value, row, index) {
                return _cellStyles(value, row, index);
            }
        },
        {title: '随访状态', field: 'revisitStatus', align: 'center', valign: 'middle', sortable: true,width:110,
            formatter: function (value, row, index) {
                if (value == 1) {
                    return "待计划";
                } else if (value == 2) {
                    return "<span>"+"回访完成"+ "</span>"
                }else if (value == 3) {
                    return "回访未完成"
                }else if(value == 4){
                    return "回访取消"
                }
            },
            cellStyle: function (value, row, index) {
                return _cellStyles(value, row, index);
            }
        },
        {title: '随访内容', field: 'remarks', align: 'center', valign: 'middle', sortable: true,width:120,
            cellStyle: function (value, row, index) {
                return _cellStyles(value, row, index);
            }
        },
        {title: '随访结果', field: 'revisitContent', align: 'center', valign: 'middle', sortable: true,width:110,
            cellStyle: function (value, row, index) {
                return _cellStyles(value, row, index);
            }
        }
    ]
    return columns;
};


FollowTableList.search = function () {
    FollowTableList.table.refresh();
};

$(function () {
    var defaultColunms = FollowTableList.initColumn();
    var reservationsId = $("#reservationsId").val();
    var table = new BSTable(FollowTableList.id, "/doctorLooked/followTableList/" + reservationsId, defaultColunms);
    table.setPaginationType("client");//客户端分页
    FollowTableList.table = table.init();
    FollowTableList.search();
    $('#FollowTableList').bootstrapTable('resetView', {height: $(window).height() - 200});
});